package com.visionork.android.tai.model;

import java.util.ArrayList;
import java.util.Collection;

import com.visionork.android.tai.model.adapter.DramaProgramAdapter;
import com.visionork.android.tai.model.adapter.TaiAdapterBase;

public class DramaProgramRepository extends ProgramRepositoryBase {
	private static final String HOME_URL = "http://sugoideas.com/idol-dramas/";
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public DramaProgramRepository() {

	}

	@SuppressWarnings("unchecked")
	@Override
	public ArrayList<Program> getPrograms(boolean useCache) {
		if (!useCache) {
			Collection<? extends Program> data = (Collection<? extends Program>) getDataAdapter()
					.getData();
			mergeData(data);
			saveToFile();
		} else {
			if (programs.size() == 0) {
				loadFromFile();
			}
		}
		return programs;
	}

	@Override
	protected String getConfigFileName() {
		return "REPOSITORY_DRAMA_PROGRAM";
	}

	@Override
	protected TaiAdapterBase getDataAdapter() {
		if (dataAdapter == null) {
			dataAdapter = new DramaProgramAdapter(HOME_URL);
		}
		return dataAdapter;
	}

}
